package com.example.demo.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.HashMap;

/*
    统一异常处理
 */

@RestControllerAdvice
public class MyExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public HashMap<String, Object> ExceptionAdvice(Exception e){
        HashMap<String, Object> result = new HashMap<>();
        result.put("state", 1);
        result.put("data", null);
        result.put("msg", e.getMessage());
        return result;
    }
}
